<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ page session="false" %>
<%@ page contentType="text/html; charset=utf-8"%>

<c:set var="first" value="${param.pageNumber == 1?true:false}"></c:set>
<c:set var="last" value="${param.pageNumber*param.pageSize>=param.total?true:false}"></c:set>
<c:set var="pageCount" value="${param.total/param.pageSize+(param.total%param.pageSize==0?0:1)}"></c:set>
<c:set var="start" value="${(param.pageNumber <= 5) ? 1 : (param.pageNumber - 4)}"></c:set>
<c:set var="end" value="${(param.pageNumber > pageCount - 5) ? pageCount : (param.pageNumber + 4)}"></c:set>

<nav class="clearfix">
  <div class="pull-left" style="margin: 7px;">
    	第${param.pageNumber}页 共<fmt:parseNumber integerOnly="true" type="number" value="${pageCount}" />页
  </div>
  <ul class="pagination pull-right" style="margin: 0;">
    <li class='hidden-xs ${first?"disabled":""}'>
	    <c:if test="${!first}">
	    	<a href="${param.url}?page=1"><span aria-hidden="true">&laquo;</span></a>
	    </c:if>
    </li>
    <li class='${first?"disabled":""}'>
	    <c:if test="${!first}">
	    	<a href="${param.url}?page=${param.pageNumber - 1}"><span aria-hidden="true">&lsaquo;</span></a>
	    </c:if>
    </li>
    <c:forEach begin="${start}" end="${end}" step="1" var="i">
	    <li class='${param.pageNumber == i?"active":""}'>
	    	<a href="${param.url}?page=${i}">${i} <span class="sr-only">(current)</span></a>
	    </li>
    </c:forEach>
    <li class='${last?"disabled":""}'>
	    <c:if test="${!last}">
	    	<a href="${param.url}?page=${param.pageNumber + 1}"><span aria-hidden="true">&rsaquo;</span></a>
	    </c:if>
    </li>
    <li class='hidden-xs ${last?"disabled":""}'>
	    <c:if test="${!last}">
	    	<a href="${param.url}?page=<fmt:parseNumber integerOnly="true" type="number" value="${pageCount}" />"><span aria-hidden="true">&raquo;</span></a>
	    </c:if>
    </li>
  </ul>
</nav>
